In [8]:
import json
import glob
import csv

Edit this next cell to choose a different country / year report:


In [9]:
fields = ['country', 'iso3c', 'year', 'coverage', 'measure', 'format', 'source', 'timespan', 'lorenz_points']

with open('./summary.csv','w') as f_summary:
    writer = csv.DictWriter(f_summary, fields)
    writer.writeheader()
    for fn in glob.glob('../jsoncache/*.json'):
        #print(fn)
        try:
            with open(fn, 'r') as f:
                d = json.loads(f.read())
                entry = dict()
                entry.update(d['dataset'])
                entry['lorenz_points'] = len(d['lorenz']['L'])
                writer.writerow(entry)
        except (ValueError, KeyError) as e:
            print(fn, e)

In [ ]: